<%@page import="helpers.HeaderHelper"%>
<%@page import="helpers.ItuneXMLUrlHelper"%>
<%@page import="helpers.CountryHelper"%>
<%@page import="helpers.UrlHelper"%>
<%@page import="helpers.StringHelper"%>
<%@page import="models.Genre"%>
<%@page import="models.FeedType"%>
<%@page import="models.Country"%>
<%@page import="models.Software"%>
<%@page import="java.util.ArrayList"%>
<%
	HeaderHelper headerHelper = (HeaderHelper) request.getAttribute("headerHelper");
    ArrayList<Software> softwares = (ArrayList<Software>) request.getAttribute("softwares");
	ArrayList<Country> countries  = (ArrayList<Country>) request.getAttribute("countries");
	ArrayList<FeedType> types = (ArrayList<FeedType>) request.getAttribute("types");
	ArrayList<String> limits = (ArrayList<String>) request.getAttribute("limits");
	ArrayList<Genre> genres = (ArrayList<Genre>) request.getAttribute("genres");
	String country = (String) request.getAttribute("country");
	String type = (String) request.getAttribute("type");
	String limit = (String) request.getAttribute("limit");
	String genre = (String) request.getAttribute("genre");
	FeedType feedtype = ItuneXMLUrlHelper.getTypeByAlias(type);
%>

<jsp:include page="/layouts/header.jsp">
    <jsp:param name="title" value="<%=headerHelper.getTitle()%>" />
    <jsp:param name="description" value="<%=headerHelper.getDescription()%>" />
    <jsp:param name="keywords" value="<%=headerHelper.getKeywords()%>" />
    <jsp:param name="ogite_name" value="<%=headerHelper.getOgite_name()%>" />
    <jsp:param name="ogtitle" value="<%=headerHelper.getOgtitle()%>" />
    <jsp:param name="ogurl" value="<%=headerHelper.getOgurl()%>" />
    <jsp:param name="ogimage" value="<%=headerHelper.getOgimage()%>" />
    <jsp:param name="ogescription" value="<%=headerHelper.getOgescription()%>" />
</jsp:include>
<script type="text/javascript">
<!--
$(document).ready(function () {
	$('.item-block .app-ranking').hover(
		function () {
			$(this).addClass("app-ranking-hover");
			$(this).find(".app-number").addClass("app-number-hover");
		},
		function () {
			$(this).removeClass("app-ranking-hover");
			$(this).find(".app-number").removeClass("app-number-hover");
		}
	);
});
//-->
</script>
		<!-- 2 - header -->
    	<div id="header">
    		<div class="block-header">
    			<div class="left-block">
    				<h1 style="color: #5090BD">Top Application Itunes</h1>
    				<div class="clear"></div>
    				<h2 style="color: #5090BD; margin: 0px 10px">Best top applications free and paid for iPhone, iPad</h2>
    			</div>
    			<div class="right-block">
    				<!-- AddThis Button BEGIN -->
					<div class="addthis_bar_large">
					    <div class="addthis_toolbox addthis_default_style">
					        <span><a class="addthis_button_facebook_like" fb:like:layout="box_count"></a></span>
					        <span><a class="addthis_button_tweet" tw:count="vertical"></a></span>
					        <span><a class="addthis_button_google_plusone" g:plusone:size="tall"></a></span>
					        <span><a class="addthis_counter"></a></span>
					    </div>
					</div>
					<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4f4f217074402877"></script>
					<!-- AddThis Button END -->
    			</div>
    			<div class="clear"></div>
    		</div>
    	</div>
    	<!-- 2 - end header -->
		
		<!-- 2 - top content -->
    	<div id="top-content">
    		<!-- 3 - top-content left -->
    		<div class="left">
    			<div class="item">
    				<div class="thumbnail" style="border: 1px solid #636363;"><img src="/images/1stapp.jpg"></div>
    				<div class="info">
    					<div class="info-top">
    						<h1><a href="#">Top Apps for iPhone, iPad</a></h1>
    						<div class="desc">
    							<h2>Best top applications free and paid for iPhone, iPad</h2>
    							<div class="clear"></div>
								<abbr title="Top iphone free, top iphone paid, top iphone grossing, top ipad free, top ipad paid, top ipad grossing, top new free, top new paid, top new grossing"> Top iphone free, top iphone paid, top iphone grossing, top ipad free, top ipad paid, top ipad grossing, top new free, top new paid, top new grossing.</abbr><br>
    						</div>
    					</div>
    					<div class="social-buttons">
    						<script type="text/javascript"><!--
							google_ad_client = "ca-pub-4975603569119809";
							/* traceip_468x15 */
							google_ad_slot = "6636286518";
							google_ad_width = 468;
							google_ad_height = 15;
							//-->
							</script>
							<script type="text/javascript"
							src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
							</script>
    					</div>
    				</div>
    			</div>
    		</div>
    		<!-- 3 - end top-content left -->
    		
    		<!-- 3 - top-content right -->
    		<div class="right">
    			<div class="extra">
    				<div class="e-item">
    					<div class="block">
    						<div class="sprite-icon"></div>
    						<span class="feature-icon">Country</span>
    					</div>
    					<div class="block">
    						<span><%=CountryHelper.getCountryByCode(country).getName() %></span>
    					</div>
    					<div class="clear"></div>
    				</div>
    				
    				<div class="e-item">
    					<div class="block">
    						<div class="sprite-icon"></div>
    						<span class="feature-icon">Category</span>
    					</div>
    					<div class="block">
    						<span><%=ItuneXMLUrlHelper.getGenreById(genre).getName() %></span>
    					</div>
    					<div class="clear"></div>
    				</div>
    				<div class="e-item">
    					<div class="block">
    						<div class="sprite-icon"></div>
    						<span class="feature-icon">Top size</span>
    					</div>
    					<div class="block">
    						<span><%=limit %></span> apps
    					</div>
    					<div class="clear"></div>
    				</div>
    			</div>
    		</div>
    		<!-- 3 - end top-content right -->
			<!-- 3 - menu-tabs -->
			<ul class="menu-tabs">
				<li class="tab <%=type.equalsIgnoreCase("topfreeapplications")? "selected" : ""%>">
					<a href="/home?<%=UrlHelper.createUrl("topfreeapplications", "feedType", request)%>">
						<div class="sprite-icon img"></div>
						<span class="tab-text">Top free</span>
					</a>
				</li>
				<li class="tab <%=type.equalsIgnoreCase("toppaidapplications")? "selected" : ""%>">
					<div class="sprite-icon img"></div>
					<a href="/home?<%=UrlHelper.createUrl("toppaidapplications", "feedType", request)%>">	
						<span class="tab-text">Top paid</span>
					</a>
				</li>
				<li class="tab <%=type.equalsIgnoreCase("topgrossingapplications")? "selected" : ""%>">
					<div class="sprite-icon img"></div>
					<a href="/home?<%=UrlHelper.createUrl("topgrossingapplications", "feedType", request)%>">
						<span class="tab-text">Top grossing</span>
					</a>
				</li>
				<li class="tab <%=type.equalsIgnoreCase("topfreeipadapplications")? "selected" : ""%>">
					<div class="sprite-icon img"></div>
					<a href="/home?<%=UrlHelper.createUrl("topfreeipadapplications", "feedType", request)%>">
						<span class="tab-text">Top free ipad</span>
					</a>
				</li>
				<li class="tab <%=type.equalsIgnoreCase("toppaidipadapplications")? "selected" : ""%>">
					<div class="sprite-icon img"></div>
					<a href="/home?<%=UrlHelper.createUrl("toppaidipadapplications", "feedType", request)%>">
						<span class="tab-text">Top paid ipad</span>
					</a>
				</li>
				<li class="tab <%=type.equalsIgnoreCase("topgrossingipadapplications")? "selected" : ""%>">
					<div class="sprite-icon img"></div>
					<a href="/home?<%=UrlHelper.createUrl("topgrossingipadapplications", "feedType", request)%>">
						<span class="tab-text">Top grossing ipad</span>
					</a>
				</li>
				<li class="tab <%=type.equalsIgnoreCase("newfreeapplications")? "selected" : ""%>">
					<div class="sprite-icon img"></div>
					<a href="/home?<%=UrlHelper.createUrl("newfreeapplications", "feedType", request)%>">
						<span class="tab-text">New free apps</span>
					</a>
				</li>
				<li class="tab <%=type.equalsIgnoreCase("newpaidapplications")? "selected" : ""%>">
					<div class="sprite-icon img"></div>
					<a href="/home?<%=UrlHelper.createUrl("newpaidapplications", "feedType", request)%>">
						<span class="tab-text">New paid apps</span>
					</a>
				</li>
			</ul>
			<!-- 3 - end menu-tabs -->
			
    	</div>
    	<!-- 2 - end top content -->
    	
    	<!-- 2 - main-content -->
    	<div class="main-content">
    		<!-- 3 - left-pane -->
    		<div class="left-pane">
    			<div class="adv top-home">
    				<script type="text/javascript"><!--
					google_ad_client = "ca-pub-4975603569119809";
					/* 1stapp 468x60 */
					google_ad_slot = "3325259718";
					google_ad_width = 468;
					google_ad_height = 60;
					//-->
					</script>
					<script type="text/javascript"
					src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
					</script>
    			</div>
    			<!-- 4 - head-link -->
    			<div class="head-link title">
    				<h1 style="color: #3472BB; margin: 6px 0pt 0pt 3px; font-size: 30px; font-weight: bold;"><%=feedtype.getName() %></h1>
					<h2 class="r-subtitle" style="margin: 17px 0pt 0pt 3px; color: rgb(72, 152, 192); font-size: 16px;">Top <%=limit %> the best applications</h2>
					<div class="clear"></div>
    			</div>
    			<!-- 4 - end head-link -->
    			
    			<!-- 4 - list-item -->
    			<div class="list-item">
    				<div class="item-block">
    					<% 
    					Software software = new Software();
    					String classRanking = "";
    					for (int i = 0; i < softwares.size(); i++) { 
    						software = softwares.get(i);
    						if (i + 1 < 10) {
    							classRanking = "large";
    						} else if( i + 1 < 100) {
    							classRanking = "medium";
    						} else {	
    							classRanking = "small";
    						}
    					%>
    					<div class="app-ranking">
    						<div class="app-number">
    							<span class="ranking <%=classRanking%>"><%=i+1%></span>
    						</div>
    						<div class="app-info">
    							<div class="inner-app">
    								<h3 class="title-app"><a href="/i/<%=StringHelper.getAlias(software.getTrackName()) + "-" + software.getTrackId()%>"><%=software.getTrackName() %></a></h3>
    								<div class="description"><%=StringHelper.cutString(software.getDescription().getValue(), 22)%>...</div>
    								<h4 class="other"><%=software.getCategory() %></h4>
    								<% if (i < 2) { %>
    								<div class="adv">
    									<script type="text/javascript"><!--
										google_ad_client = "ca-pub-4975603569119809";
										/* traceip_468x15 */
										google_ad_slot = "6636286518";
										google_ad_width = 468;
										google_ad_height = 15;
										//-->
										</script>
										<script type="text/javascript"
										src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
										</script>
    								</div>
    								<% } %>
    							</div>
    							<div class="image">
    								<a href="/i/<%=StringHelper.getAlias(software.getTrackName()) + "-" + software.getTrackId()%>"><img src="<%=software.getArtworkUrl100()%>"></img></a>
    								<div class="price"><%=software.getPrice() == 0 ? "Free" : "$" + software.getPrice()%></div>
    							</div>
    						</div>
    						<div class="clear"></div>
    					</div>
    					<% } %>
    				</div>
    			</div>
    			<!-- 4 - end list-item -->
    		</div>
    		<!-- 3 - end left-pane -->
    		
    		<!-- 3 - right-pane -->
    		<jsp:include page="/elements/right.jsp" />
    		<!-- 3 - end right-pane -->
    		
    		<div class="clear"></div>
    	</div>
    	<!-- 2 - end main-content -->
<jsp:include page="/layouts/footer.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>